package com.finalcial.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.finalcial.dao.ApprovalDao;
import com.finalcial.dao.OtherDao;
import com.finalcial.dao.ProcessTrackingDao;
import com.finalcial.dao.SingleDao;
import com.finalcial.dao.WorkDao;
import com.finalcial.service.DeclarationInformationService;

@Service
public class DeclarationInformationServiceImpl implements DeclarationInformationService {
	@Autowired
	private SingleDao singleDao; //申请信息所有信息的显示
	@Autowired
	private ProcessTrackingDao processTrackingDao; //流程跟踪所有相关信息的显示
	@Autowired
	private WorkDao workDao;
	@Autowired
	private OtherDao otherDao;
	@Autowired
	private ApprovalDao approvalDao;
	
	/**
	 * 分页显示所有补单界面信息
	 */
	@Override
	public List<Map<String, Object>> listSingMsgByStaff(Integer userId, Integer startPos, Integer pageSize) {
		return singleDao.listSingMsgByStaff(userId, startPos, pageSize);
	}

	@Override
	public List<Map<String, Object>> listProcessMsg(String reimbursementId) {
		return processTrackingDao.listProcessMsg(reimbursementId);
	}

	@Override
	public List<Map<String, Object>> getEssentialInformation(
			@Param("reimbursementId") String reimbursementId) {
		return workDao.getEssentialInformation(reimbursementId);
	}

	@Override
	public List<Map<String, Object>> getOtherInformation(String reimbursementId) {
		return otherDao.getOtherInformation(reimbursementId);
	}

	@Override
	public List<Map<String, Object>> getSingMsg(Integer userId,
			String userName, Integer startMoney, Integer EndMoney,
			String approvalStateName,String reimbursementTypeName) {
		return singleDao.getSingMsg(userId, userName, startMoney, EndMoney, approvalStateName, reimbursementTypeName);
	}

	/**
	 * 添加补单信息
	 */
	@Override
	public Integer insertsupplementMs(String reimbursementId,
			String supplementReason, String invoiceIdExplain,
			Integer invoiceNumber, Date supplementTime, Integer invoiceMoney,String workStateName,Integer userId) {
			Integer updateApprovalInteger = approvalDao.insertWorkStateByWork(reimbursementId, workStateName, userId);
			Integer insertInteger = singleDao.insertsupplementMs(userId,reimbursementId, supplementReason, invoiceIdExplain, invoiceNumber, supplementTime, invoiceMoney);
			Integer updateInteger = singleDao.updateReimbursemenMoney(reimbursementId, invoiceMoney);
			Integer total = insertInteger+updateInteger+updateApprovalInteger;
			System.out.println(total);
			return total;
		
	}

	/**
	 * 获取补单界面所有信息
	 */
	@Override
	public Integer listSingMsgByStaffCounts(Integer userId) {
		return singleDao.listSingMsgByStaffCounts(userId);
	}

	
	

	
	
	

}
